﻿using SH.Common.DataDictionary;
using SH.Customer.Domain.CustomerClass;
using SH.Customer.ErrorCodeEnum;
using SH.Customer.Infrastructure.IRepository;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SH.Customer.Infrastructure.Repository
{
    public class MemberCardRepository : BaseRepository<MemberCard>, IMemberCardRepository
    {
        private readonly ISqlSugarClient _context;
        public MemberCardRepository(ISqlSugarClient context) : base(DbManger.BizDb)
        {
            _context = DbManger.BizDb;
        }

        /// <summary>
        /// 添加会员
        /// </summary>
        /// <param name="member"></param>
        /// <returns></returns>
        public async Task<int> AddRetunIdentityAsync(MemberCard member)
        {
            var result =  await _context.Insertable<MemberCard>(member).ExecuteReturnIdentityAsync();
            return result;
        }

        /// <summary>
        /// 修改会员信息
        /// </summary>
        /// <param name="member"></param>
        /// <returns></returns>
        public async Task<int> UpdRetunIdentityAsync(MemberCard member)
        {
            var result = await _context.Insertable<MemberCard>(member).ExecuteReturnIdentityAsync();
            return result;
        }
    }
}
